﻿using PowerBooking.RSE.Poco;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Objects;
using System.Linq;
using System.Text;
using PowerBooking.RSE.IRepository;

namespace PowerBooking.RSE.Repository.Repositories
{
    /// <summary>
    /// 筛选项仓储
    /// </summary>
    public class FilterRepository : RestaurantSpiderEngineRepository, IFilterRepository
    {
        public FilterRepository(IUnitOfWork unitOfWork) : base(unitOfWork) { }

        /// <summary>
        /// 根据城市ID查询筛选项集合
        /// </summary>
        /// <returns></returns>
        public IEnumerable<FilterPoco> QueryFiltersByCityID(int cityID)
        {
            return Context.Filters.Where(f => f.CityID == cityID);
        }

        /// <summary>
        /// 插入一个筛选项
        /// </summary>
        /// <param name="spiderPoco"></param>
        /// <returns></returns>
        public void InsertFilter(FilterPoco filterPoco)
        {
            Context.Filters.AddObject(filterPoco);
            Context.SaveChanges(SaveOptions.None);
        }
    }
}
